package org.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import org.example.pojo.ItripImage;
import org.example.vo.recommend.room.Recommend_HotelRoom;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ItripImageMapper extends BaseMapper<ItripImage> {
    @Select("select  ih.id,min(ihr.roomPrice) roomPrice from itrip_hotel_room ihr inner join itrip_hotel ih on ihr.hotelId = ih.id\n" +
            "where ih.redundantCityName = #{city}\n" +
            "group by ihr.hotelId")
    @Results({
            @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
            @Result(column="roomPrice", property="roomPrice", jdbcType= JdbcType.DECIMAL)
    })
    List<Recommend_HotelRoom> queryByMinPrice(String city);
}
